<template>
    <div class="homes">
        <!--轮播图-->
        <div style="background-color: #fa3534;
    height: 100px;
    border-bottom-right-radius: 4em .2em;
    border-bottom-left-radius: 4em .2em;padding-top:.5rem ;">
            <van-swipe class="my-swipe" :autoplay="2000" indicator-color="white">
                <van-swipe-item v-for="(v,i) in swip"><img :src="v.pic_url" alt=""
                                                           style="width: 100%;height: 176px;vertical-align: bottom"
                                                           @click="goS(v)">
                </van-swipe-item>
            </van-swipe>
        </div>
        <!--小分类-->
        <div style="margin-top: 3.6rem">
            <ul style="list-style: none;margin: 10px 15px;display: flex;flex-wrap: wrap;align-items: center;box-orient: horizontal;box-direction: normal;flex-direction: row;">
                <li v-for="(x,i) in typs" @click="gotp(x)" style="width: 20%;">
                    <div style="text-align: center;box-sizing: border-box;padding:5px .4rem;margin: 0 auto">
                        <img :src="x.image" alt="" style="width: 100%;">
                        <p style="font-size: .5rem">{{x.navigation_name}}</p>
                    </div>
                </li>
            </ul>
        </div>
        <!--商品内容-->
        <div style="margin: 5px 10px 10px 10px;
    border-radius: 5px;
    overflow: hidden;">
            <div v-for="(v,i) in msg" class="qq">
                <img v-for="x in v.blockList" :src="x.block_value" alt="" class="xx" v-if="x.block_type=='IMAGE'">
                <div v-for="x in v.blockList" v-if="x.block_type=='GOODS'">
                    <img :src="x.block_value.goods_image" alt="">
                    <p>{{x.block_value.goods_name}}</p>
                    <p><span style="    color: rgb(250, 53, 52);
    font-size: 10px;
    font-weight: 600;">￥</span><span style="    color: rgb(250, 53, 52);
    font-size: 16px;
    font-weight: 600;">{{x.block_value.price}}</span></p>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import jsp from '../../../Api/Api'

    export default {
        name: "home",
        data() {
            return {
                swip: [],
                typs: [],
                msg: []
            }
        },
        created() {
            //轮播图
            jsp.getSwiper().then(data => {
                // console.log(data.data)
                this.swip = data.data
            }).catch(error => console.log(error))
            //小分类
            jsp.getLittletype().then(data => {
                // console.log(data.data)
                this.typs = data.data
            }).catch(error => console.log(error))
            //商品数据
            jsp.getHomedata().then(data => {
                // console.log(JSON.parse(data.data.page_data))
                this.msg = JSON.parse(data.data.page_data)
            }).catch(error => console.log(error))
        },
        methods: {
            goS(v) {
                console.log(v)
            },
            gotp(x) {
                console.log(x)
            },
        }
    }
</script>

<style scoped>
    .homes{
        margin-top: 102px;
    }
    .my-swipe {
        border-radius: 15px;
        overflow: hidden;
        width: 90%;
        margin: 0 auto;
        box-shadow: 0 5px 5px lightslategray;
    }

    .my-swipe .van-swipe-item {
        width: 100%;
        color: #fff;
        font-size: 20px;
        /*line-height: 150px;*/
        text-align: center;
    }

    .xx:nth-child(1) {
        width: 100%;
    }

    .qq:nth-child(2) {
        display: flex;
        justify-content: space-around;
    }

    .qq:nth-child(2) > img {
        width: 30%;
        height: 106px;
        border: 1px solid #dfdfdf;
        border-radius: 5px;
    }

    .qq:nth-child(3) {
        margin-top: .5rem;
        margin-bottom: .2rem;
        display: flex;
        justify-content: space-around;
    }

    .qq:nth-child(3) > img {
        width: 30%;
        height: 106px;
        border: 1px solid #dfdfdf;
        border-radius: 5px;
    }

    .qq:nth-child(5) {
        position: relative;
        overflow: hidden;
        width: 100%;
        margin-bottom: .2rem;
    }

    .qq:nth-child(5) img:nth-of-type(1) {
        float: left;
        width: 50%;
        margin-right: 1%;
    }

    .qq:nth-child(5) img:nth-of-type(2) {
        width: 50%;
        float: left;
        margin-right: 1%;
        margin-top: 1px;
    }

    .qq:nth-child(5) img:nth-of-type(3) {
        position: absolute;
        top: 0;
        width: 49%;
    }

    .qq:nth-child(6) {
        height: 104px;
        display: flex;
        justify-content: space-between;
        margin-bottom: .3rem;
    }

    .qq:nth-child(6) img {
        width: 24.7%;
    }

    .qq:nth-child(7) {
        display: flex;
        height: 122px;
        justify-content: space-between;
        margin-bottom: .2rem;
    }

    .qq:nth-child(7) img {
        width: 33%;
    }

    .qq:nth-child(10) {
        display: flex;
        height: 126px;
        justify-content: space-between;
        margin-bottom: .1rem;
    }

    .qq:nth-child(10) img:nth-of-type(1) {
        width: 50%;
    }

    .qq:nth-child(10) img:nth-of-type(2), .qq:nth-child(10) img:nth-of-type(3) {
        width: 24.5%;
    }

    .qq:nth-child(11) {
        display: flex;
        height: 112px;
        justify-content: space-between;
        margin-bottom: .1rem;
    }

    .qq:nth-child(11) img {
        width: 24.8%;
    }

    .qq:nth-child(13),.qq:nth-child(14),.qq:nth-child(15),.qq:nth-child(16) {
        display: flex;
        justify-content: space-between;
        margin-bottom: 5px;
    }
    .qq:nth-child(16){
        margin-bottom: 70px;
    }
    .qq:nth-child(13) div,.qq:nth-child(14) div,.qq:nth-child(15) div,.qq:nth-child(16) div {
        background-color: #ffffff;
        width: 48%;
        overflow: hidden;
        margin: 5px 0;
        border-radius: 10px;
    }

    .qq:nth-child(13) div img,.qq:nth-child(14) div img,.qq:nth-child(15) div img,.qq:nth-child(16) div img {
        width: 100%;
    }

    .qq:nth-child(13) div p:nth-of-type(1),.qq:nth-child(14) div p:nth-of-type(1),.qq:nth-child(15) div p:nth-of-type(1),.qq:nth-child(16) div p:nth-of-type(1) {
        margin: 10px;
        height: 40px;
        width: 150px;
        overflow: hidden;
        word-break: break-all;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        font-size: 15px;
        font-weight: 500;
    }
    .qq:nth-child(13) div p:nth-of-type(2),.qq:nth-child(14) div p:nth-of-type(2),.qq:nth-child(15) div p:nth-of-type(2),.qq:nth-child(16) div p:nth-of-type(2){
        margin:10px;
        margin-top:0 ;
    }
</style>